from faker import Faker
from functools import wraps

def coroutine(f):
    @wraps(f)
    def wrapper(*args,**kwargs):
        g=f(*args,**kwargs)
        next(g)
        return g
    return wrapper

def sub_coroutine():
    l=[]
    while True:
        value=yield
        if value == 'CLOSE':
            break
        l.append(value)
    return sorted(l)

@coroutine
def dele_coroutine():
    while True:
        l=yield from sub_coroutine()
        print('Sorted List: ',l)
        print('------------------')

def main():
    fake=Faker().country_code
    nest_country_list=[ [ fake() for i in range(3) ] for j in range(3) ]
    for country_list in nest_country_list:
        print('Country Code List: ',country_list)
        c=dele_coroutine()
        for country in country_list:
            c.send(country)
        c.send('CLOSE')

main()
